<?php

/*

  Action	$2

  +1 Buy; +$1
  When you discard this from play, you may put one of your Treasures from play on top of your deck.

 */

class Herbalist extends Card implements iAction, iKingdom, iAlchemy {

    public function __construct() {
        parent::__construct("Herbalist", 2);
        $this->undoPlay = false;
        $this->undoBuy = true;
    }

    public function play(Game $game, $isRealCard) {
        $game->addBuys(1);
        $game->addMoney(1);
         ScreenDisplay::addScreenMessage($game, true, "get  +1 buy and +1$", "gets +1 buy and +1$");
		$game->cardActionFinished();
        return true;
    }
    
        public function getDescription() {
        return array(
            "+1 Buy",
            "+$1",
            "When you discard this from play, you may put one of your Treasures from play on top of your deck.");
    }

    public function cleanup(Game $game) {
        $playArea = $game->getPlayArea();
        $treasures = array();
        foreach ($playArea as $card) {
            if ($card instanceof iTreasure) {
                $treasures[] = $card;
            }
        }

        $treasures = getUniqueCards($treasures);
        if (sizeof($treasures) > 0) {
            
            $treasures[] = new Option(1, 'None');
            $output = MySocket::GetUserReply($game,  Input_ChooseOne, $treasures, 1, 1, null, "Choose a treasure to put on top of your deck");
            $card_name = $output[0];
            if ($card_name != "None") {
                $card = $game->moveCardFromPileToPile($card_name, PlayArea, DrawPile);
                 ScreenDisplay::addScreenMessage($game, true, "return ".  nicePrint($card)." on top of your deck ","returns ".  ScreenDisplay::$LMSG." on top of his deck");
            }
        }
        $game->cardCleanupFinished();

        return true;
    }

}

?>